Mysql创建用户并授权以及开启远程访问

您所在的位置:网站首页 mysql 创建用户 并授权 Mysql创建用户并授权以及开启远程访问

Mysql创建用户并授权以及开启远程访问

2024-07-09 16:57| 来源: 网络整理| 查看: 265

一、创建用户并授权

1、登录mysql

  mysql -u root -p

2、创建数据库

  create database test;//以创建test为例

3、创建用户

创建user01,只能本地访问

  create user user01@'localhost' identified by 'password';

创建user02,可以远程访问

  create user user02@'%' identified by 'password'

4、修改用户密码

以user01为例:

  set password for 'user01'@'localhost'=password('anotherpassword')

5、授权

授予user01管理test的全部权限

  grant all privileges on test.* to user01;

授予user02查看权限,并修改密码

  grant select on *.* to 'user02'@'%' identified by 'anotherpassword';

     



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3